package com.lfx.concurrent;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CompletTableFutureMain {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<String> stringCompletableFuture = new CompletableFuture<>();
        new Thread(){
            @Override
            public void run() {
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                stringCompletableFuture.complete("hello completableFuture");

            }
        }.start();

        String result = stringCompletableFuture.get();
        System.out.println("result"+result);

    }
}
